$(function () {
    //获取重要用户
    // getImportantUserList();
    //获取当前台风信息
    // getTyphoonInfo();
    //获取抢修车辆配置情况
    // getCarList();
    //获取文成百丈漈水库
    // getReservoir();
    //获取重要用户失电数
    // getImportantUserNumber();

    //第一屏
    // //根据时间获取主网受损
    // getMainDamagedInfo();
    // //根据时间获取主网跳闸
    // getMainTripInfo();
    // //根据时间获取副网受损
    // getSubDamagedInfo();
    // //根据时间获取副网跳闸
    // getSubTripInfo();

    //变电信息220v
    getSubstation220();
    //变电信息110v
    getSubstation110();
    //变电信息35
    getSubstation35();

    //变电信息220v
    getTrans220();
    //变电信息110v
    getTrans110();
    //变电信息35
    getTrans35();

    //副网线路断线情况
    getSubDisconnection();
    //副网线路倒塔情况
    getSubTopple();
    //副网受损整体
    getSubDamaged();

    // //温州各区县用户影响
    // getcityElectricity('温州');
    // //温州各区县线路受损情况
    // getwzPowerLossing();
    // //温州各区县已恢复信息
    // getRecovery();

    //时间
    getAlock();

    //预警状态
    getWarningConfig();


})

function getWarningConfig() {
    $.ajax({
        url: basepath + '/warningConfiguration/dp',
        type: 'POST',
        contentType: 'application/json;charset=UTF-8',
        dataType: 'json',
        success: function (res) {
            powerInfo = res.data.threshold;
            miniMapInfo = res.data.thresholdInfo;
            $('.power-exp .red p').html('>' + res.data.threshold.advanced);
            $('.power-exp .yellow p').html(res.data.threshold.middle);
            $('.power-exp .blue p').html(res.data.threshold.base);

            $('.minimap-exp .darkBlue p').html('>' + res.data.thresholdInfo.advanced);
            $('.minimap-exp .blue p').html(res.data.thresholdInfo.middle);
            $('.minimap-exp .lightBlue p').html(res.data.thresholdInfo.base);

            if (res.data.warningConfiguration.warningGrade == "台风蓝色预警") {
                $(".myTip").css({ "background": "url('./static/img/myTip1.png')", "background-size": "100% 100%" });
                $(".myTip").html(res.data.warningConfiguration.warningGrade != '暂无台风' ? res.data.warningConfiguration.warningGrade : '');
                // mapType=='active'?$(".myTip").show():$(".myTip").hide();
            } else if (res.data.warningConfiguration.warningGrade == "台风黄色预警") {
                $(".myTip").css({ "background": "url('./static/img/myTip2.png')", "background-size": "100% 100%" });
                $(".myTip").html(res.data.warningConfiguration.warningGrade != '暂无台风' ? res.data.warningConfiguration.warningGrade : '');
                // mapType=='active'?$(".myTip").show():$(".myTip").hide();
            } else if (res.data.warningConfiguration.warningGrade == "台风橙色预警") {
                $(".myTip").css({ "background": "url('./static/img/myTip3.png')", "background-size": "100% 100%" });
                $(".myTip").html(res.data.warningConfiguration.warningGrade != '暂无台风' ? res.data.warningConfiguration.warningGrade : '');
                // mapType=='active'?$(".myTip").show():$(".myTip").hide();
            } else if (res.data.warningConfiguration.warningGrade == "台风红色预警") {
                $(".myTip").css({ "background": "url('./static/img/myTip4.png')", "background-size": "100% 100%" });
                $(".myTip").html(res.data.warningConfiguration.warningGrade != '暂无台风' ? res.data.warningConfiguration.warningGrade : '');
                // mapType=='active'?$(".myTip").show():$(".myTip").hide();
            } else {
                $(".myTip").hide();
            }
        }
    });
}
function getAlock() {
    setInterval(function () {
        var date = new Date();
        var month, dates, hours, min, seconds;
        month = (date.getMonth() + 1);
        dates = date.getDate();
        hours = date.getHours();
        min = date.getMinutes();
        seconds = date.getSeconds();
        if (month < 10) {
            month = "0" + month;
        }
        if (dates < 10) {
            dates = "0" + dates;
        }
        if (hours < 10) {
            hours = "0" + hours;
        }
        if (min < 10) {
            min = "0" + min;
        }
        if (seconds < 10) {
            seconds = "0" + seconds;
        }
        var clocks = date.getFullYear() + "-" + month + "-" + dates + " " + hours + ":" + min + ":" + seconds;
        // var now=date.getFullYear()+"年"+month+"月"+(dates-1)+"日";
        $(".clock").text(clocks);
        // $("#count .main-date").text("截至" + now);
    }, 1000)
}

// function getImportantUserNumber(){
//     $.ajax({
//         type: "post",
//         async: false,
//         url: basepath + "/client/getLossNumbers",
//         contentType: 'application/json',
//         dataType: "json",
//         data: {},
//         success: function (data) {
//             $(".aside-tab-item span:eq(1)").text(data.data);
//         },
//         error: function () {
//             console.log('fail');
//         }
//     });
// }

function getImportantUserList() {
  /*   $.ajax({
        type: "post",
        async: false,
        url: basepath + "/client/webBigBanner",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (data) {
            //$("#showcontent").text("Result:"+data.result)  
            var data = data.data;
            $(".aside-tab-item span:eq(0)").text(data.length);
            var n = 0;
            $('.aside-user-list').html('');
            for (var i = 0; i < data.length; i++) {//" + data[i].lng.toFixed(2) + "E," + data[i].lat.toFixed(2) + "N
                if (data[i].circuitStatusStr == "失电") {
                    n++;
                    $("<div class='aside-user-item' onclick='RightImportant(" + i + ")'><div class='aside-user-txt1' >" + (i + 1) + "-</div><div class='aside-user-txt2'>" + data[i].clientName + `</div>  <el-checkbox></el-checkbox>  <div class='aside-user-txt3' style='color:red'>` + data[i].circuitStatusStr + "</div>").appendTo(".aside-user-list");
                } else if (data[i].circuitStatusStr == "正常") {
                    $("<div class='aside-user-item' onclick='RightImportant(" + i + ")'><div class='aside-user-txt1'>" + (i + 1) + "-</div><div class='aside-user-txt2'>" + data[i].clientName + "</div><div class='aside-user-txt3' style='color:green'>" + data[i].circuitStatusStr + "</div>").appendTo(".aside-user-list");
                } else {
                    n++;
                    $("<div class='aside-user-item' onclick='RightImportant(" + i + ")'><div class='aside-user-txt1'>" + (i + 1) + "-</div><div class='aside-user-txt2'>" + data[i].clientName + "</div><div class='aside-user-txt3'>" + data[i].circuitStatusStr + "</div>").appendTo(".aside-user-list");
                }
            }
            $(".aside-tab-item span:eq(1)").text(n);

        },
        error: function () {
            console.log('fail');
        }
    }); */
}

/* function RightImportant(i) {
    for (let x = 0; x < powerDots.length; x++) {
        $('.rightImportant').eq(x).removeClass('icon_green');
    }
    powerDots[i].setZIndex(9999)
    $('.rightImportant').parent().eq(i).css({
        "z-index": "9999"
    }).siblings().css({
        "z-index": "999"
    });
    $('.rightImportant').eq(i).addClass('icon_green');
} */
function getTyphoonInfo() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/typhoon/listAllIsActive",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (data) {
            if (data.code == 200 && data.data.length != 0) {
                var data = data.data[0];
                $("#typhoonInfo .aside-info").html("<img src='./static/img/icon04.png' />" + data.tfid + data.name + "【" + data.strong + "】");
                $("#typhoonInfo .aside-info-list .aside-info-item:eq(0) span").text(replaceDate(data.time));
                $("#typhoonInfo .aside-info-list .aside-info-item:eq(1) span").text(data.speed + "米/秒");
                $("#typhoonInfo .aside-info-list .aside-info-item:eq(2) span").text(parseFloat(data.lng) + "E," + parseFloat(data.lat) + "N");
                $("#typhoonInfo .aside-info-list .aside-info-item:eq(3) span").text(data.movespeed + "公里/小时");
                $("#typhoonInfo .aside-info-list .aside-info-item:eq(4) span").text(data.power + "级");
                $("#typhoonInfo .aside-info-list .aside-info-item:eq(5) span").text(data.movedirection);
                $("#typhoonInfo .aside-info-list2 .aside-info-item2:eq(3)").text(replaceDate(data.time));
                $("#typhoonInfo .aside-info-list2 .aside-info-item2:eq(4)").text(data.power);
                $("#typhoonInfo .aside-info-list2 .aside-info-item2:eq(5)").text(data.speed);
            }

        },
        error: function () {
            console.log('fail');
        }
    });
}

function replaceDate(date) {
    var date1 = '';
    if (date) {
        date1 = date.replace('年', '/');
        date1 = date1.replace('月', '/');
        date1 = date1.replace('日', '');
    }

    return date1;
}

function getCarList() {
    $.ajax({
        type: "post",
        async: false,
        url: basepath + "/repair/car/webBigBanner",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (data) {
            var data = data.data;
            //发电车
            $("#carList .aside-subContext2:eq(0)  .aside-txt1:eq(0) .aside-count").text(data.electricCarTotal);
            $("#carList .aside-subContext2:eq(0)  .aside-txt2:eq(0) .aside-count").text(data.electricCarWorkOutNum);
            $("#carList .aside-subContext2:eq(0)  .aside-txt1:eq(1) .aside-count").text(data.electricCarAwait);
            //皮卡
            $("#carList .aside-subContext2:eq(1)  .aside-txt1:eq(0) .aside-count").text(data.pickUpTruckTotal);
            $("#carList .aside-subContext2:eq(1)  .aside-txt2:eq(0) .aside-count").text(data.pickUpTruckWorkOutNum);
            $("#carList .aside-subContext2:eq(1)  .aside-txt1:eq(1) .aside-count").text(data.pickUpTruckAwait);
            //作业车
            $("#carList .aside-subContext2:eq(2)  .aside-txt1:eq(0) .aside-count").text(data.jobCarTotal);
            $("#carList .aside-subContext2:eq(2)  .aside-txt2:eq(0) .aside-count").text(data.jobCarWorkOutNum);
            $("#carList .aside-subContext2:eq(2)  .aside-txt1:eq(1) .aside-count").text(data.jobCarAwait);
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getSubstation220() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/substation/220",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (res) {
            var data = res.data;
            $("#subContext1 .aside-txt .aside-txt1:eq(0) .aside-count").text(data.amount || 0);
            $("#subContext1 .aside-txt .aside-txt1:eq(1) .aside-count").text((data.amount || 0) - (data.number || 0));
            $("#subContext1 .aside-txt .aside-txt1:eq(2) .aside-count").text(data.number || 0);

            var circle = data.rate ? data.rate * 360 : 0;
            if (circle > 180) {
                circle = 360 - circle;
                $("#subContext1 .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext1 .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext1 .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getSubstation110() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/substation/110",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (res) {
            var data = res.data;
            $("#subContext2 .aside-txt .aside-txt1:eq(0) .aside-count").text(data.amount || 0);
            $("#subContext2 .aside-txt .aside-txt1:eq(1) .aside-count").text((data.amount || 0) - (data.number || 0));
            $("#subContext2 .aside-txt .aside-txt1:eq(2) .aside-count").text(data.number || 0);

            var circle = data.rate ? data.rate * 360 : 0;
            if (circle > 180) {
                circle = 360 - circle;
                $("#subContext2 .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext2 .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext2 .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getSubstation35() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/substation/35",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (res) {
            var data = res.data;
            $("#subContext3 .aside-txt .aside-txt1:eq(0) .aside-count").text(data.amount || 0);
            $("#subContext3 .aside-txt .aside-txt1:eq(1) .aside-count").text((data.amount || 0) - (data.number || 0));
            $("#subContext3 .aside-txt .aside-txt1:eq(2) .aside-count").text(data.number || 0);

            var circle = data.rate ? data.rate * 360 : 0;
            if (circle > 180) {
                circle = 360 - circle;
                $("#subContext3 .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext3 .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext3 .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getTrans220() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/trans/220",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (res) {
            var data = res.data;
            $("#subContext4 .aside-txt .aside-txt1:eq(0) .aside-count").text(data.amount || 0);//总数
            $("#subContext4 .aside-txt .aside-txt1:eq(1) .aside-count").text((data.amount || 0) - (data.number || 0));//已恢复
            $("#subContext4 .aside-txt .aside-txt1:eq(2) .aside-count").text(data.number || 0);//未恢复
            $("#subContext4 .aside-txt .aside-txt1:eq(2) .aside-count-item:eq(0)").text(data.trouble1 ? "受损 ············· " + data.trouble1 : "受损 ············· 0");
            $("#subContext4 .aside-txt .aside-txt1:eq(2) .aside-count-item:eq(1)").text(data.trouble2 ? "跳闸 ············· " + data.trouble2 : "跳闸 ············· 0");


            var circle = data.rate ? data.rate * 360 : 0;
            if (circle > 180) {
                circle = 360 - circle;
                $("#subContext4 .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext4 .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext4 .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getTrans110() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/trans/110",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (res) {
            var data = res.data;
            $("#subContext5 .aside-txt .aside-txt1:eq(0) .aside-count").text(data.amount || 0);//总数
            $("#subContext5 .aside-txt .aside-txt1:eq(1) .aside-count").text((data.amount || 0) - (data.number || 0));//已恢复
            $("#subContext5 .aside-txt .aside-txt1:eq(2) .aside-count").text(data.number || 0);//未恢复
            $("#subContext5 .aside-txt .aside-txt1:eq(2) .aside-count-item:eq(0)").text(data.trouble1 ? "受损 ············· " + data.trouble1 : "受损 ············· 0");
            $("#subContext5 .aside-txt .aside-txt1:eq(2) .aside-count-item:eq(1)").text(data.trouble2 ? "跳闸 ············· " + data.trouble2 : "跳闸 ············· 0");


            var circle = data.rate ? data.rate * 360 : 0;
            if (circle > 180) {
                circle = 360 - circle;
                $("#subContext5 .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext5 .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext5 .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}


function getTrans35() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/trans/35",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (res) {
            var data = res.data;
            $("#subContext6 .aside-txt .aside-txt1:eq(0) .aside-count").text(data.amount || 0);//总数
            $("#subContext6 .aside-txt .aside-txt1:eq(1) .aside-count").text((data.amount || 0) - (data.number || 0));//已恢复
            $("#subContext6 .aside-txt .aside-txt1:eq(2) .aside-count").text(data.number || 0);//未恢复
            $("#subContext6 .aside-txt .aside-txt1:eq(2) .aside-count-item:eq(0)").text(data.trouble1 ? "受损 ············· " + data.trouble1 : "受损 ············· 0");
            $("#subContext6 .aside-txt .aside-txt1:eq(2) .aside-count-item:eq(1)").text(data.trouble2 ? "跳闸 ············· " + data.trouble2 : "跳闸 ············· 0");


            var circle = data.rate ? data.rate * 360 : 0;
            if (circle > 180) {
                circle = 360 - circle;
                $("#subContext6 .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext6 .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext6 .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getSubDisconnection() {
    // var startTime=new Date().getFullYear()+"-"+(new Date().getMonth() + 1)+"-"+new Date().getDate()+" 00:00:00";
    // var endtTime=new Date().getFullYear()+"-"+(new Date().getMonth() + 1)+"-"+new Date().getDate()+" 23:59:59";
    // var phoonTime={startTime: startTime,endTime: endtTime};
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/branch/disconnection",
        contentType: 'application/json;charset=UTF-8',
        dataType: "json",
        success: function (data) {
            var data = data.data;
            $("#subContext7 .aside-context:eq(0) .aside-subContext-title-item:eq(0)").text(data.amount ? "线路总数 | " + data.amount : "线路总数 | 0");
            $("#subContext7 .aside-context:eq(0) .aside-subContext-title-item:eq(1)").text(data.number ? "故障数量 | " + data.number : "故障数量 | 0");
            $("#subContext7 .aside-context:eq(0) .aside-subContext-title-item:eq(2)").text(data.rate ? "故障占比 | " + data.rate + '%' : "故障占比 | 0%");

            $("#subContext7 .aside-context:eq(0) .aside-txt .aside-txt1:eq(0) .aside-count").text(data.number || 0);
            $("#subContext7 .aside-context:eq(0) .aside-txt .aside-txt1:eq(1) .aside-count").text(data.recovered || 0);
            $("#subContext7 .aside-context:eq(0) .aside-txt .aside-txt1:eq(2) .aside-count").text(data.unrecovered || 0);
            $("#subContext7 .aside-context:eq(0) .aside-txt .aside-txt1:eq(3) .aside-count").text(data.recoveredRate || 0);
            var circle = data.rate * 360 || 0;
            if (circle > 180) {
                circle = 360 - circle;
                $("#subContext7 .aside-context:eq(0) .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext7 .aside-context:eq(0) .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext7 .aside-context:eq(0) .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getSubTopple() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/branch/topple",
        contentType: 'application/json',
        dataType: "json",
        success: function (data) {
            var data = data.data;
            $("#subContext7 .aside-context:eq(2) .aside-subContext-title-item:eq(0)").text(data.amount ? "用户总数 | " + data.amount : "用户总数 | 0");
            $("#subContext7 .aside-context:eq(2) .aside-subContext-title-item:eq(1)").text(data.number ? "影响数量 | " + data.number : "影响数量 | 0");
            $("#subContext7 .aside-context:eq(2) .aside-subContext-title-item:eq(2)").text(data.amount && data.number ? "影响占比 | " + Math.floor(data.number / data.amount * 1000) / 10 + '%' : "影响占比 | 0%");

            $("#subContext7 .aside-context:eq(2) .aside-txt .aside-txt1:eq(0) .aside-count").text(data.number || 0);
            $("#subContext7 .aside-context:eq(2) .aside-txt .aside-txt1:eq(1) .aside-count").text(data.recovered || 0);
            $("#subContext7 .aside-context:eq(2) .aside-txt .aside-txt1:eq(2) .aside-count").text(data.unrecovered || 0);
            $("#subContext7 .aside-context:eq(2) .aside-txt .aside-txt1:eq(3) .aside-count").text(data.rate || 0);
            var circle = data.rate * 360 || 0;
            if (circle > 180) {

                circle = 360 - circle;
                $("#subContext7 .aside-context:eq(2) .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext7 .aside-context:eq(2) .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext7 .aside-context:eq(2) .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getSubDamaged() {
    $.ajax({
        type: "get",
        async: false,
        url: basepath + "/repair/schedule/branch/damaged",
        contentType: 'application/json',
        dataType: "json",
        success: function (data) {
            var data = data.data;
            $("#subContext7 .aside-context:eq(1) .aside-subContext-title-item:eq(0)").text(data.amount ? "台区总数 | " + data.amount : "台区总数 | 0");
            $("#subContext7 .aside-context:eq(1) .aside-subContext-title-item:eq(1)").text(data.number ? "受损数量 | " + data.number : "受损数量 | 0");
            $("#subContext7 .aside-context:eq(1) .aside-subContext-title-item:eq(2)").text(data.amount && data.number ? "受损占比 | " + Math.floor(data.number / data.amount * 1000) / 10 + "%" : '受损占比 | 0%');

            $("#subContext7 .aside-context:eq(1) .aside-txt .aside-txt1:eq(0) .aside-count").text(data.number || 0);
            $("#subContext7 .aside-context:eq(1) .aside-txt .aside-txt1:eq(1) .aside-count").text(data.recovered || 0);
            $("#subContext7 .aside-context:eq(1) .aside-txt .aside-txt1:eq(2) .aside-count").text(data.unrecovered || 0);
            $("#subContext7 .aside-context:eq(1) .aside-txt .aside-txt1:eq(3) .aside-count").text(data.rate || 0);
            var circle = data.rate * 360 || 0;
            if (circle > 180) {

                circle = 360 - circle;
                $("#subContext7 .aside-context:eq(1) .aside-circle-right-deg").css("transform", "rotate(0deg" + ")");
                $("#subContext7 .aside-context:eq(1) .aside-circle-left-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            } else {
                circle = 180 - circle;
                $("#subContext7 .aside-context:eq(1) .aside-circle-right-deg").css("transform", "rotate(-" + circle + "deg" + ")");
            }
        },
        error: function () {
            console.log('fail');
        }
    });
}


function getcityElectricity(name) {
    $.ajax({
        type: "post",
        async: false,
        contentType: 'application/json',
        url: basepath + "/suffererinfo/dp/cityElectricity",
        dataType: "json",
        data: JSON.stringify({ areaName: name }),
        success: function (data) {
            var data = data.data;
            $("#count .main-date").text("截至" + data.gmtCreate.substring(0, 13) + "时");
            $("#count .main-tab-item:eq(0) .main-tab-txt2 a").text(data.malfunction);
            $("#count .main-tab-item:eq(1) .main-tab-txt2 a").text(data.notRecover);
            $("#count .main-tab-item:eq(2) .main-tab-txt2").text(data.additional);
            $("#count .main-tab-item:eq(3) .main-tab-txt2 a").text(data.recoverUsers);
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getwzPowerLossing() {
    $.ajax({
        type: "post",
        async: false,
        url: basepath + "/suffererinfo/dp/wzPowerLossing",
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (data) {
            var data = data.data;
            _Charts4(data);
            //_Charts5(data);
        },
        error: function () {
            console.log('fail');
        }
    });
}

function _Charts4(data) {
    var dom = document.getElementById("chart4");
    var yData = [], _data = [], allData = [], recoverUsers = [];
    $('#echarts-list').html('');
    for (var i = 0; i < data.length; i++) {
        yData.push((data[i].unit));
        _data.push(data[i].notRecover);
        allData.push(data[i].malfunction);
        recoverUsers.push(data[i].recoverUsers);
        rate = data[i].notRecover / data[i].malfunction;
        var circle = rate * 360 || 0;
        if (circle < 180) {
            circle = circle + 180;
            $('#echarts-list').append("<div class='echarts-item'>\
            <div class='echarts-item-title'>\
                <div class='echarts-item-txt1'>"+ data[i].unit + "</div>\
                <div class='echarts-item-txt2'>线路总数："+ data[i].malfunction + "条</div>\
            </div>\
            <div class='shanxing shanxing1'>\
                <div class='sx1'></div>\
                <div class='sx2' style='transform: rotate("+ circle + "deg);' ></div>\
                <div class='sx_t'>"+ data[i].notRecover + "</div>\
            </div>\
        </div>");
        } else {
            circle = circle > 360 ? 360 : circle;
            $('#echarts-list').append("<div class='echarts-item'>\
            <div class='echarts-item-title'>\
                <div class='echarts-item-txt1'>"+ data[i].unit + "</div>\
                <div class='echarts-item-txt2'>线路总数："+ data[i].malfunction + "条</div>\
            </div>\
            <div class='shanxing shanxing2'>\
                <div class='sx1' style='transform: rotate("+ circle + "deg);'></div>\
                <div class='sx2' ></div>\
                <div class='sx_t'>"+ data[i].notRecover + "</div>\
            </div>\
        </div>");
        }
    }
    allData = allData.reverse();
    yData = yData.reverse();
    recoverUsers = recoverUsers.reverse();

    var myChart4 = echarts.init(dom);
    var option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            },
            textStyle: {
                fontSize: fontSize(0.12),
            }
        },
        legend: {
            data: ['已恢复数量', '线路故障数量'],
            textStyle: {
                fontSize: fontSize(0.12),
                color: "rgb(0,222,237)"
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            top: '5%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: 'rgb(0,222,237)',//x轴的颜色
                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: ['rgb(39,71,82)'],
                    width: 1,
                    type: 'solid'
                }
            },
            axisLabel: {
                fontSize: fontSize(0.12),
            }
        },
        yAxis: {
            type: 'category',
            axisLine: {
                lineStyle: {
                    color: 'rgb(0,222,237)',//x轴的颜色
                    fontSize: '0'
                }
            },
            axisLabel: {
                fontSize: '0',
            },
            data: yData,
            padding: [0, fontSize(1), 0, 0],
        },
        series: [
            {
                name: '已恢复数量',
                type: 'bar',
                stack: '总量',
                label: {
                    show: true,
                    position: 'right',
                    fontSize: fontSize(0.12),
                    color: 'rgb(0,222,237)',
                },
                data: recoverUsers,
                itemStyle: {
                    color: new echarts.graphic.LinearGradient(
                        0, 0, 1, 0,
                        [
                            { offset: 0, color: '#031b27' },
                            { offset: 0.5, color: '#028fa1' },
                            { offset: 1, color: '#01e3f9' }
                        ]
                    )
                    // normal: {
                    //     color: 'rgb(0,222,237)',//x轴的颜色
                    // }
                },
                barWidth: fontSize(0.2),
            },
            {
                name: '线路故障数量',
                type: 'bar',
                stack: '总量',
                label: {
                    show: true,
                    position: 'right',
                    fontSize: fontSize(0.12),
                    color: 'rgba(0,222,237,0.4)',
                },
                data: allData,
                itemStyle: {
                    normal: {
                        color: 'rgba(0,222,237,0.2)',//x轴的颜色
                        position: 'left'
                    }
                },
                barWidth: fontSize(0.2),
            }
        ]
    };
    myChart4.getZr().on('click', params => {
        console.log(params.topTarget.__zr.painter.root.textContent.substring(0, 2));
        let pointInPixel = [params.offsetX, params.offsetY]
        if (myChart4.containPixel('grid', pointInPixel)) {
            let xIndex = myChart4.convertFromPixel({ seriesIndex: 0 }, [params.offsetX, params.offsetY])[1]
            console.log(xIndex);
        }
    })
    myChart4.setOption(option, true);
}


// function _Charts5(data) {
//     var dom = document.getElementById("chart5");
//     var yData = [], _data = [], allData = [], recoverUsers = [];
//     for (var i = 0; i < data.length; i++) {
//         yData.push((data[i].unit));
//         _data.push(data[i].notRecover);
//         allData.push(data[i].malfunction);
//         recoverUsers.push(data[i].recoverUsers);
//     }
//     var myChart5 = echarts.init(dom);
//     var option = {
//         tooltip: {
//             trigger: 'axis',
//             axisPointer: {            // 坐标轴指示器，坐标轴触发有效
//                 type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
//             },
//             textStyle: {
//                 fontSize: fontSize(0.12),
//             }
//         },
//         legend: {
//             data: ['未恢复数量'],
//             textStyle: {
//                 fontSize: fontSize(0.12),
//                 color: "rgb(237,165,47)"
//             }
//         },
//         grid: {
//             left: '3%',
//             right: '0%',
//             bottom: '3%',
//             top: '5%',
//             containLabel: true
//         },
//         xAxis: {
//             type: 'value',
//             axisLine: {
//                 lineStyle: {
//                     color: 'rgb(0,222,237)',//x轴的颜色
//                 }
//             },
//             splitLine: {
//                 show: true,
//                 lineStyle: {
//                     color: ['rgb(39,71,82)'],
//                     width: 1,
//                     type: 'solid'
//                 }
//             },
//             axisLabel: {
//                 fontSize: fontSize(0.12),
//             },
//             inverse:true
//         },
//         yAxis: {
//             type: 'category',
//             position:"right",
//             axisLine: {
//                 lineStyle: {
//                     color: 'rgb(0,222,237)',
//                     fontSize:'0'
//                 }
//             },
//             data: yData,
//             axisLabel: {
//                 fontSize:'0',
//             }
//         },
//         series: [
//             {
//                 name: '未恢复数量',
//                 type: 'bar',
//                 label: {
//                     show: true,
//                     position: 'left',
//                     fontSize: fontSize(0.12),
//                     color: 'rgb(237,165,47)',
//                 },
//                 itemStyle: {
//                     color: new echarts.graphic.LinearGradient(
//                         0, 0, 1, 0,
//                         [
//                             {offset: 0, color: '#292c23'},
//                             {offset: 0.5, color: '#85652a'},
//                             {offset: 1, color: '#f5a931'}
//                         ]
//                     )
//                     // normal: {
//                     //     color: 'rgb(237,165,47)',//x轴的颜色
//                     // }
//                 },
//                 barWidth: fontSize(0.2),
//                 data: _data
//             }
//         ]
//     };
//     myChart5.setOption(option, true);
// }



function _Charts2(data) {
    var xData = [], _data = [];
    var hours = new Date().getHours();
    for (var i = 0; i < data.length; i++) {
        if (hours >= (data[i].timeNode).slice(11, 13)) {
            _data.push(data[i].currentWagerLine || 0);
        } else {
            _data.push(0);
        }
        xData.push((data[i].timeNode).slice(11, 13));

    }
    var dom = document.getElementById("chart2");
    var myChart = echarts.init(dom);

    var option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'line'        // 默认为直线，可选为：'line' | 'shadow'
            },
            textStyle: {
                fontSize: fontSize(0.12),
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: xData,//["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23"]
            axisLine: {
                lineStyle: {
                    color: 'rgb(0,222,237)',//x轴的颜色
                }
            },
            splitLine: { show: false },//去除网格线
            axisLabel: {
                textStyle: {
                    fontSize: fontSize(0.12),
                }
            }
        },
        yAxis: {
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: 'rgb(0,222,237)',//x轴的颜色
                }
            },
            splitLine: { show: false },//去除网格线
            axisLabel: {
                textStyle: {
                    fontSize: fontSize(0.12),
                }
            }
        },
        grid: {
            top: fontSize(0.1),
            left: fontSize(0.35),
            right: fontSize(0.12),
            bottom: fontSize(0.2)
        },
        series: [{
            data: _data,
            name: '实时水位',
            type: 'line',
            areaStyle: {
                color: 'rgb(0,222,237)',
                opacity: '0.2'
            },
            itemStyle: {
                normal: {
                    color: "rgb(0,222,237)",//折线点的颜色
                    lineStyle: {
                        color: "rgb(0,222,237)"//折线的颜色
                    },
                },
                fontSize: fontSize(0.12),
            }
        }]
    };
    myChart.setOption(option, true);
    myChart.resize();
}
function _Charts3(data) {
    var xData = data.time, _data = data.kwh;
    // var hours=new Date().getHours();
    // for (var i = 0; i < data.length; i++) {
    //     if (hours>=(data[i].timeNode).slice(11, 13)) {
    //         _data.push(data[i].currentCapacity)
    //     }else{
    //         _data.push(0);
    //     }
    //     xData.push((data[i].timeNode).slice(11, 13));
    // }

    var dom = document.getElementById("chart3");
    var myChart = echarts.init(dom);
    var option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'line'        // 默认为直线，可选为：'line' | 'shadow'
            },
            textStyle: {
                fontSize: fontSize(0.12),
            }
        },
        xAxis: {
            type: 'category',
            data: xData,
            axisLine: {
                lineStyle: {
                    color: 'rgb(0,222,237)',//x轴的颜色
                }
            },
            splitLine: { show: false },//去除网格线
        },
        yAxis: {
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: 'rgb(0,222,237)',//x轴的颜色
                }
            },
            splitLine: { show: false },//去除网格线
        },
        grid: {
            top: fontSize(0.1),
            left: fontSize(0.35),
            right: fontSize(0.12),
            bottom: fontSize(0.3)
        },
        series: [{
            name: '实时电量',
            data: _data,
            type: 'bar',
            barWidth: '60%',
            itemStyle: {
                normal: {
                    color: "rgb(0,222,237)",//折线点的颜色
                    lineStyle: {
                        color: "rgb(0,222,237)"//折线的颜色
                    }
                },
                fontSize: fontSize(0.12),
            },
        }]

        // xAxis: {
        //     type: 'category',
        //     boundaryGap: false,
        //     data:xData ,//
        //     axisLine: {
        //         lineStyle: {
        //             color: 'rgb(0,222,237)',//x轴的颜色
        //         }
        //     },
        //     splitLine: { show: false },//去除网格线
        //     axisLabel: {
        //         textStyle: {
        //             fontSize: fontSize(0.12),
        //         }
        //     }
        // },
        // yAxis: {
        //     type: 'value',
        //     axisLine: {
        //         lineStyle: {
        //             color: 'rgb(0,222,237)',//x轴的颜色
        //         }
        //     },
        //     splitLine: { show: false },//去除网格线
        //     axisLabel: {
        //         textStyle: {
        //             fontSize: fontSize(0.12),
        //         }
        //     }
        // },
        // grid: {
        //     top: fontSize(0.12),
        //     left: fontSize(0.35),
        //     right: fontSize(0.12),
        //     bottom: fontSize(0.2)
        // },
        // series: [{
        //     data: _data,
        //     name: '实时库容',
        //     barWidth: '40%',
        //     type: 'bar',
        //     areaStyle: {
        //         color: 'rgb(0,222,237)',
        //         opacity: '0.2'
        //     },
        //     itemStyle: {
        //         normal: {
        //             color: "rgb(0,222,237)",//折线点的颜色
        //             lineStyle: {
        //                 color: "rgb(0,222,237)"//折线的颜色
        //             }
        //         },
        //         fontSize: fontSize(0.12),
        //     },
        //     textStyle: {
        //         fontSize: fontSize(0.12),
        //     }
        // }]
    };
    myChart.setOption(option, true);
}
function _3dCharts1(id, amount, number) {
    var normal = amount - number;
    Highcharts.chart(id, {
        chart: {
            type: 'pie',
            options3d: {
                enabled: true,
                alpha: 45,
                beta: 0
            },
            backgroundColor: 'rgba(0,0,0,0)',
            fontSize: fontSize(0.12),
            style: {
                fontSize: fontSize(0.12),
            }
        },
        title: {
            text: false,
            style: {
                fontSize: '0px'
            }
        },
        tooltip: {
            style: {
                fontSize: fontSize(0.12),
            }
        },
        labels: {                  //图表标袭签
            exporting: {
                enabled: false  //设置导出zd按钮不可用    
            },
        },
        accessibility: {
            point: {
                valueSuffix: '%'
            }
        },
        plotOptions: {
            pie: {
                allowPointSelect: false,
                cursor: 'pointer',
                depth: fontSize(0.15),
                dataLabels: {
                    enabled: false,
                },
                style: {
                    fontSize: fontSize(0.12),
                }
            }
        },
        exporting: {
            enabled: false
        },
        credits: {
            enabled: false
        },
        colors: [
            "#00e7ff", "#ffb031"
        ],
        series: [{
            type: 'pie',
            data: [
                ['正常数量', normal],
                ['受损数量', number],
            ],
            textStyle: {
                fontSize: fontSize(0.12),
            }
        }]
    });
}

function fontSize(res) {
    let docEl = document.documentElement,
        clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    if (!clientWidth) return;
    let fontSize = 100 * (clientWidth / 1920);
    return res * fontSize;

}